package com.hechao;

import java.util.ArrayList;
import java.util.List;

public class StudentManage {
	
	private List<Student> list = new ArrayList<>();

	public StudentManage(List<Student> list) {
		
		this.list = list;
	}
	/**
	 * 不考虑复姓的情况下,查询同姓的学生
	 * 
	 * @param name
	 * @return
	 */
	public List<Student> findStudentsByName(char name) {
		
		List<Student> students = new ArrayList<>();
		for (Student s : students) {
			
			String xm = s.getName();
			
			char x = xm.charAt(0);
			//比较姓氏 是否 相等
			if(x == name) {
				students.add(s);
			}
		}
		return students;
	}
	/**
	 * 增加学生
	 * @param student
	 */
	public void addStudent(Student student) {
		
		list.add(student);
	}
}
